@if(app()->isLocal())

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Wave Installation</title>
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/2.0.4/tailwind.min.css">
    </head>
    <body class="bg-zinc-50">

        @if(Request::get('complete'))

            @php
            

                \Illuminate\Support\Facades\Artisan::call('db:seed', [
                '--force' => true
                ]);

                \Illuminate\Support\Facades\Artisan::call('storage:link');

                Auth::login(\App\Models\User::first());

                // Remove everything in the public/composer directory
                $composerDir = public_path('/composer');
                if (file_exists($composerDir)) {
                    $files = glob($composerDir.'/*');
                    foreach ($files as $file) {
                        if (is_file($file)) {
                            unlink($file);
                        }
                    }
                }

                // Remove the composer directory
                if (file_exists($composerDir)) {
                    rmdir($composerDir);
                }

                @endphp

                <div class="flex flex-col justify-center items-center w-screen h-screen">
                <svg class="-mt-12 w-9 h-9" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 27 27" fill="none"><g fill="currentColor"><path d="M21.508 13.52c1.096 1.048 2.456.12 2.425-1.647a3.282 3.282 0 0 0-.632-1.878c-.382-.498-.866-.769-1.331-.742-1.568.089-1.874 2.92-.462 4.267ZM25.462 15.698c.18-.925 0-1.535-.06-1.736-.177-.52-.459-.646-.573-.676-1.098-.297-2.012 2.679-1.208 3.93.544.844 1.541.022 1.84-1.518ZM22.976 6.382c-.898.21-.015 3.05 1.152 3.708.747.419 1.1-.36.713-1.574a4.657 4.657 0 0 0-.832-1.525c-.38-.442-.767-.672-1.034-.609ZM18.174 9.37c1.307.922 2.769.17 2.557-1.317-.1-.6-.401-1.146-.854-1.552-.204-.173-.826-.7-1.591-.588-1.393.203-1.695 2.339-.112 3.456ZM20.714 13.793c-.16-.198-.496-.608-1.121-.708-1.756-.277-3.05 2.048-2.005 3.606 1.009 1.506 3.139.858 3.507-1.073a2.364 2.364 0 0 0-.381-1.825ZM26.459 12.157a6.3 6.3 0 0 0-.327-1.6c-.064-.16-.258-.651-.477-.624-.562.068-.254 3.43.357 3.906.334.261.541-.525.447-1.682ZM20.72 3.994c-.726-.528-1.108-.518-1.3-.416-.72.381.279 2.448 1.632 2.866.826.256 1.172-.347.712-1.238a3.804 3.804 0 0 0-1.044-1.212ZM22.734 19.18c.34-.8.18-1.31.12-1.5a.927.927 0 0 0-.433-.49c-1.146-.554-2.794 1.533-2.317 2.938.425 1.255 2.02.483 2.63-.947ZM17.116 9.842a2.18 2.18 0 0 0-1.457-.645c-1.87-.067-2.83 2.127-1.528 3.503 1.251 1.326 3.48.592 3.615-1.19.064-.898-.463-1.477-.63-1.668ZM24.513 6.842c.218.056-.007-.487-.483-1.161a8.951 8.951 0 0 0-.894-1.075c-.313-.315-.555-.495-.616-.457-.234.145 1.574 2.586 1.993 2.693ZM25.621 17.335c-.408-.169-1.695 2.434-1.514 3.06.1.344.695-.325 1.158-1.302.202-.404.347-.835.432-1.279.055-.366-.024-.457-.076-.479ZM14.446 5.54c1.05.8 2.522.286 2.38-.829-.071-.558-.51-.927-.652-1.048-.351-.285-.8-.422-1.25-.381-1.078.126-1.534 1.452-.478 2.258ZM17.01 19.179a1.529 1.529 0 0 0-.316-1.407 1.637 1.637 0 0 0-.89-.519c-1.601-.357-2.92 1.29-2.077 2.592.823 1.268 2.878.85 3.283-.666ZM21.475 3.803c.23 0 .095-.343-.478-.849a6.936 6.936 0 0 0-1.071-.762c-.408-.237-.721-.36-.777-.307-.137.127 1.732 1.923 2.326 1.918ZM23.087 20.72c-.5-.407-2.265 1.518-2.146 2.342.068.476 1.05-.159 1.684-.962.442-.556.514-.907.541-1.04.012-.073.026-.253-.079-.34ZM17.237 1.8c-.712-.382-1.002-.287-1.111-.191-.45.38.366 1.55 1.4 1.726.64.109.898-.277.542-.81-.256-.382-.69-.64-.83-.726ZM18.975 22.245c.325-.577.173-.932.107-1.083a.86.86 0 0 0-.223-.256c-.91-.66-2.64.643-2.372 1.789.264 1.129 1.858.671 2.488-.45ZM11.83 13.246c-1.603-.228-2.63 1.66-1.616 2.969a1.779 1.779 0 0 0 3.204-.844c.114-.808-.323-1.334-.487-1.535a1.911 1.911 0 0 0-1.102-.59ZM10.71 8.565c.898 1.034 2.76.452 2.931-.916a1.529 1.529 0 0 0-.434-1.249 1.585 1.585 0 0 0-.933-.448c-1.432-.165-2.47 1.568-1.564 2.613ZM17.57 25.047c-.042.453.988.021 1.622-.586.35-.331.394-.53.415-.626a.25.25 0 0 0-.03-.156c-.31-.46-1.944.648-2.008 1.368ZM17.153 1.28c.41.19.669.249.75.216.114-.047-.091-.239-.467-.436a5.856 5.856 0 0 0-.918-.375c-.087-.027-.526-.164-.593-.127.021.062.858.546 1.228.722ZM6.988 12.102c.669.945 2.292.552 2.522-.923a1.627 1.627 0 0 0-.302-1.264 1.27 1.27 0 0 0-.814-.458c-1.28-.162-2.187 1.544-1.406 2.645ZM11.822 20.888c-1.08-.135-1.651.898-.954 1.727.697.829 2.01.581 2.124-.405.06-.506-.248-.83-.364-.953a1.48 1.48 0 0 0-.806-.369ZM11.894 2.644c.397.469 1.543.264 1.635-.443a.665.665 0 0 0-.225-.572.805.805 0 0 0-.44-.19c-.737-.077-1.38.722-.97 1.205ZM15.31 24.617a.58.58 0 0 0-.046-.655.687.687 0 0 0-.277-.19c-.764-.298-1.675.363-1.416 1.022.258.66 1.381.548 1.74-.177ZM14.52 1.183c.351.04.606-.114.41-.382A1.096 1.096 0 0 0 14.51.51c-.396-.155-.561-.086-.625-.03-.21.186.065.634.635.704ZM8.482 4.998c.258.698 1.623.476 2.005-.533.113-.298.095-.59-.044-.801a.584.584 0 0 0-.234-.198c-.782-.37-2.022.733-1.727 1.532ZM9.432 18.922a1.618 1.618 0 0 0-.468-1.109c-.124-.115-.5-.465-1.05-.437-1.028.051-1.28 1.403-.416 2.224.82.774 1.938.38 1.934-.678ZM14.863 26.317c-.031.237.62.014.942-.19.26-.167.28-.277.286-.324a.158.158 0 0 0-.013-.056c-.154-.273-1.166.204-1.215.57ZM5.71 15.016a1.757 1.757 0 0 0-.302-1.072c-.095-.118-.315-.394-.676-.415-.886-.05-1.232 1.476-.513 2.268.601.667 1.452.217 1.492-.781ZM4.92 8.127c.264.628 1.322.33 1.695-.674.177-.476.065-.762.023-.872a.532.532 0 0 0-.262-.258c-.732-.31-1.792 1.005-1.457 1.804ZM12.055.693a.357.357 0 0 0 .133-.2.056.056 0 0 0-.015-.04c-.119-.107-.942.203-.95.434-.008.188.513.098.832-.194ZM10.474 24.48a1.17 1.17 0 0 0-.405-.504c-.308-.222-.596-.25-.749-.206-.442.124-.161.768.469 1.075.543.265.819.018.685-.365ZM12.72 25.845a.707.707 0 0 0-.458-.117c-.286.032-.328.251-.095.451.287.246.764.256.738-.054a.421.421 0 0 0-.184-.28ZM9.224 2.101c.181-.2.203-.31.213-.358a.103.103 0 0 0-.032-.095c-.242-.2-1.35.539-1.317.877.029.268.697.061 1.136-.424ZM6.944 21.802a1.686 1.686 0 0 0-.437-.608c-.44-.36-.705-.293-.798-.247-.452.223.057 1.233.757 1.502.461.177.688-.13.477-.647h.001ZM3.05 10.945c.066-.258.059-.529-.02-.783-.081-.217-.211-.27-.286-.286-.535-.095-1.018 1.225-.654 1.783.255.39.784.1.96-.714ZM5.565 4.448a1.12 1.12 0 0 0 .245-.483c0-.041.009-.11-.036-.144-.254-.19-1.218.762-1.146 1.131.052.258.566-.02.937-.504ZM3.074 17.794c-.17-.212-.35-.317-.486-.279-.41.113-.15 1.188.376 1.554.37.258.54-.11.436-.587a1.764 1.764 0 0 0-.326-.688ZM2.26 7.383c.062-.123.107-.253.134-.388.006-.044.017-.136-.03-.15-.173-.054-.669.822-.598 1.048.05.157.32-.157.493-.514v.004ZM.79 14.1c-.023-.06-.084-.224-.164-.213-.221.03-.176 1.09.054 1.275.135.108.217-.222.198-.58A1.785 1.785 0 0 0 .79 14.1Z"></path></g></svg>
                <div class="flex flex-col items-center p-10 mx-auto mt-8 w-full max-w-lg bg-white rounded-xl border shadow-xl border-zinc-100">
                    <h1 class="text-2xl font-semibold text-black">Successfully Installed 🎉</h1>
                    <p class="mt-5 text-zinc-500">Click the continue button below to view your new SAAS application.</p>
                    <a href="/" class="flex justify-center px-4 py-2 mt-8 w-full text-lg font-medium text-white bg-gray-900 rounded-md border border-transparent transition duration-150 ease-in-out hover:bg-gray-800 focus:outline-none focus:border-gray-900 focus:shadow-outline-wave active:bg-gray-900">
                        Continue
                    </a>
                </div>
            </div>

        @else

            @php

                try {
                    $user = \App\Models\User::first();
                    header('Location: /');
                    exit;
                } catch (\Illuminate\Database\QueryException $e) {
                    // Continue with the installation process
                }

                // Make sure the database directory exists
                $databaseDir = dirname(database_path('database.sqlite'));
                if (!\Illuminate\Support\Facades\File::exists($databaseDir)) {
                    \Illuminate\Support\Facades\File::makeDirectory($databaseDir, 0755, true);
                }

                if (!\Illuminate\Support\Facades\File::exists(database_path('database.sqlite'))) {
                    \Illuminate\Support\Facades\File::put(database_path('database.sqlite'), '');
                }
                \Illuminate\Support\Facades\Artisan::call('migrate', [
                    '--force' => true
                    ]);
            @endphp

            <div class="flex flex-col justify-center items-center w-screen h-screen">
                <svg class="-mt-12 w-9 h-9" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 27 27" fill="none"><g fill="currentColor"><path d="M21.508 13.52c1.096 1.048 2.456.12 2.425-1.647a3.282 3.282 0 0 0-.632-1.878c-.382-.498-.866-.769-1.331-.742-1.568.089-1.874 2.92-.462 4.267ZM25.462 15.698c.18-.925 0-1.535-.06-1.736-.177-.52-.459-.646-.573-.676-1.098-.297-2.012 2.679-1.208 3.93.544.844 1.541.022 1.84-1.518ZM22.976 6.382c-.898.21-.015 3.05 1.152 3.708.747.419 1.1-.36.713-1.574a4.657 4.657 0 0 0-.832-1.525c-.38-.442-.767-.672-1.034-.609ZM18.174 9.37c1.307.922 2.769.17 2.557-1.317-.1-.6-.401-1.146-.854-1.552-.204-.173-.826-.7-1.591-.588-1.393.203-1.695 2.339-.112 3.456ZM20.714 13.793c-.16-.198-.496-.608-1.121-.708-1.756-.277-3.05 2.048-2.005 3.606 1.009 1.506 3.139.858 3.507-1.073a2.364 2.364 0 0 0-.381-1.825ZM26.459 12.157a6.3 6.3 0 0 0-.327-1.6c-.064-.16-.258-.651-.477-.624-.562.068-.254 3.43.357 3.906.334.261.541-.525.447-1.682ZM20.72 3.994c-.726-.528-1.108-.518-1.3-.416-.72.381.279 2.448 1.632 2.866.826.256 1.172-.347.712-1.238a3.804 3.804 0 0 0-1.044-1.212ZM22.734 19.18c.34-.8.18-1.31.12-1.5a.927.927 0 0 0-.433-.49c-1.146-.554-2.794 1.533-2.317 2.938.425 1.255 2.02.483 2.63-.947ZM17.116 9.842a2.18 2.18 0 0 0-1.457-.645c-1.87-.067-2.83 2.127-1.528 3.503 1.251 1.326 3.48.592 3.615-1.19.064-.898-.463-1.477-.63-1.668ZM24.513 6.842c.218.056-.007-.487-.483-1.161a8.951 8.951 0 0 0-.894-1.075c-.313-.315-.555-.495-.616-.457-.234.145 1.574 2.586 1.993 2.693ZM25.621 17.335c-.408-.169-1.695 2.434-1.514 3.06.1.344.695-.325 1.158-1.302.202-.404.347-.835.432-1.279.055-.366-.024-.457-.076-.479ZM14.446 5.54c1.05.8 2.522.286 2.38-.829-.071-.558-.51-.927-.652-1.048-.351-.285-.8-.422-1.25-.381-1.078.126-1.534 1.452-.478 2.258ZM17.01 19.179a1.529 1.529 0 0 0-.316-1.407 1.637 1.637 0 0 0-.89-.519c-1.601-.357-2.92 1.29-2.077 2.592.823 1.268 2.878.85 3.283-.666ZM21.475 3.803c.23 0 .095-.343-.478-.849a6.936 6.936 0 0 0-1.071-.762c-.408-.237-.721-.36-.777-.307-.137.127 1.732 1.923 2.326 1.918ZM23.087 20.72c-.5-.407-2.265 1.518-2.146 2.342.068.476 1.05-.159 1.684-.962.442-.556.514-.907.541-1.04.012-.073.026-.253-.079-.34ZM17.237 1.8c-.712-.382-1.002-.287-1.111-.191-.45.38.366 1.55 1.4 1.726.64.109.898-.277.542-.81-.256-.382-.69-.64-.83-.726ZM18.975 22.245c.325-.577.173-.932.107-1.083a.86.86 0 0 0-.223-.256c-.91-.66-2.64.643-2.372 1.789.264 1.129 1.858.671 2.488-.45ZM11.83 13.246c-1.603-.228-2.63 1.66-1.616 2.969a1.779 1.779 0 0 0 3.204-.844c.114-.808-.323-1.334-.487-1.535a1.911 1.911 0 0 0-1.102-.59ZM10.71 8.565c.898 1.034 2.76.452 2.931-.916a1.529 1.529 0 0 0-.434-1.249 1.585 1.585 0 0 0-.933-.448c-1.432-.165-2.47 1.568-1.564 2.613ZM17.57 25.047c-.042.453.988.021 1.622-.586.35-.331.394-.53.415-.626a.25.25 0 0 0-.03-.156c-.31-.46-1.944.648-2.008 1.368ZM17.153 1.28c.41.19.669.249.75.216.114-.047-.091-.239-.467-.436a5.856 5.856 0 0 0-.918-.375c-.087-.027-.526-.164-.593-.127.021.062.858.546 1.228.722ZM6.988 12.102c.669.945 2.292.552 2.522-.923a1.627 1.627 0 0 0-.302-1.264 1.27 1.27 0 0 0-.814-.458c-1.28-.162-2.187 1.544-1.406 2.645ZM11.822 20.888c-1.08-.135-1.651.898-.954 1.727.697.829 2.01.581 2.124-.405.06-.506-.248-.83-.364-.953a1.48 1.48 0 0 0-.806-.369ZM11.894 2.644c.397.469 1.543.264 1.635-.443a.665.665 0 0 0-.225-.572.805.805 0 0 0-.44-.19c-.737-.077-1.38.722-.97 1.205ZM15.31 24.617a.58.58 0 0 0-.046-.655.687.687 0 0 0-.277-.19c-.764-.298-1.675.363-1.416 1.022.258.66 1.381.548 1.74-.177ZM14.52 1.183c.351.04.606-.114.41-.382A1.096 1.096 0 0 0 14.51.51c-.396-.155-.561-.086-.625-.03-.21.186.065.634.635.704ZM8.482 4.998c.258.698 1.623.476 2.005-.533.113-.298.095-.59-.044-.801a.584.584 0 0 0-.234-.198c-.782-.37-2.022.733-1.727 1.532ZM9.432 18.922a1.618 1.618 0 0 0-.468-1.109c-.124-.115-.5-.465-1.05-.437-1.028.051-1.28 1.403-.416 2.224.82.774 1.938.38 1.934-.678ZM14.863 26.317c-.031.237.62.014.942-.19.26-.167.28-.277.286-.324a.158.158 0 0 0-.013-.056c-.154-.273-1.166.204-1.215.57ZM5.71 15.016a1.757 1.757 0 0 0-.302-1.072c-.095-.118-.315-.394-.676-.415-.886-.05-1.232 1.476-.513 2.268.601.667 1.452.217 1.492-.781ZM4.92 8.127c.264.628 1.322.33 1.695-.674.177-.476.065-.762.023-.872a.532.532 0 0 0-.262-.258c-.732-.31-1.792 1.005-1.457 1.804ZM12.055.693a.357.357 0 0 0 .133-.2.056.056 0 0 0-.015-.04c-.119-.107-.942.203-.95.434-.008.188.513.098.832-.194ZM10.474 24.48a1.17 1.17 0 0 0-.405-.504c-.308-.222-.596-.25-.749-.206-.442.124-.161.768.469 1.075.543.265.819.018.685-.365ZM12.72 25.845a.707.707 0 0 0-.458-.117c-.286.032-.328.251-.095.451.287.246.764.256.738-.054a.421.421 0 0 0-.184-.28ZM9.224 2.101c.181-.2.203-.31.213-.358a.103.103 0 0 0-.032-.095c-.242-.2-1.35.539-1.317.877.029.268.697.061 1.136-.424ZM6.944 21.802a1.686 1.686 0 0 0-.437-.608c-.44-.36-.705-.293-.798-.247-.452.223.057 1.233.757 1.502.461.177.688-.13.477-.647h.001ZM3.05 10.945c.066-.258.059-.529-.02-.783-.081-.217-.211-.27-.286-.286-.535-.095-1.018 1.225-.654 1.783.255.39.784.1.96-.714ZM5.565 4.448a1.12 1.12 0 0 0 .245-.483c0-.041.009-.11-.036-.144-.254-.19-1.218.762-1.146 1.131.052.258.566-.02.937-.504ZM3.074 17.794c-.17-.212-.35-.317-.486-.279-.41.113-.15 1.188.376 1.554.37.258.54-.11.436-.587a1.764 1.764 0 0 0-.326-.688ZM2.26 7.383c.062-.123.107-.253.134-.388.006-.044.017-.136-.03-.15-.173-.054-.669.822-.598 1.048.05.157.32-.157.493-.514v.004ZM.79 14.1c-.023-.06-.084-.224-.164-.213-.221.03-.176 1.09.054 1.275.135.108.217-.222.198-.58A1.785 1.785 0 0 0 .79 14.1Z"></path></g></svg>
                <div class="flex flex-col items-center p-10 mx-auto mt-8 w-full max-w-lg bg-white rounded-2xl border shadow-sm border-zinc-100">
                    <h1 class="text-2xl font-semibold text-black">Welcome to Wave</h1>
                    <p class="mt-5 text-zinc-500">If you're ready to get started, click on the 'Install Wave' button below. In this future this installation screen will have a few setup options.</p>
                    <a href="/install?complete=true" class="flex justify-center px-4 py-2 mt-8 w-full text-lg font-medium text-white bg-gray-900 rounded-md border border-transparent transition duration-150 ease-in-out hover:bg-gray-800 focus:outline-none focus:border-gray-900 focus:shadow-outline-wave active:bg-gray-900">
                        Install Wave
                    </a>
                </div>
            </div>

        @endif

    </body>
    </html>


@endif
